import css from './message.css'
import add from  './component/add';
import edit from  './component/edit';
import {Vue,axios,navigation,commonVue,loadsection} from '../../assets/js/base.js';
import SYS_Message_sel from  '../../API/SYS_Message_sel.js';
import SYS_Message_del from  '../../API/SYS_Message_del.js';

new Vue({
    el: '#main',
    data:{
      fullScreen:false,//是否全屏
      currentMenu:"message.html",//当前菜单
      tableLoading:false,
      pageState:false,
      addSettingDialog:false,
      editSettingDialog:false,
      loadSection:false,
      table_data_total:0,
      table_data:[],
      search_data:{
        pageNo:1,
        pageSize:10
      },
      currentID:"",
      currentName:"",
      currentItem:null
    },
    mounted:function(){
      this.search();
    },
    methods:{
      globalEvent:function(){
        commonVue.$emit('navSelected');
      },
      del(Id){
        this.$MessageBox.confirm(`确定要删除吗？`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          SYS_Message_del({Id:Id}).then(data => {
            this.$Message({
                message:"删除成功"
            });
            this.getTableData();
          }).catch(message => {
            this.$Message({
                message
            });
          });
        }).catch(message => {

        });


      },
      openEditSettingDialog(Id,item){
        this.currentID = Id;
        this.currentItem = item;
        this.editSettingDialog = true;
      },
      confirmEditSettingDialog(){
        this.editSettingDialog = false;
        this.getTableData();
      },
      cancelEditSettingDialog(){
        this.editSettingDialog = false;
      },
      confirmAddSettingDialog(){
        this.addSettingDialog = false;
        this.getTableData();
      },
      openAddSettingDialog(){
        this.addSettingDialog = true;
      },
      cancelAddSettingDialog(){
        this.addSettingDialog = false;
      },
      checkPermission(){
        return true;
      },
      getTableData(){
        this.tableLoading = true;
        SYS_Message_sel(this.search_data).then((data,total) => {
          this.table_data = data;
          this.table_data_total = total;
          this.tableLoading = false;
        }).catch(message => {
          this.tableLoading = false;
          this.$Message({
              message
          });
          console.log("SYS_Message_sel异常:",message)
        });
      },
      search() {
          this.getTableData();
      },
    },
    components: {
      navigation,
      loadsection,
      'add':add,
      'edit':edit
    }
})
